package com.menhai.personmanagement.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.menhai.personmanagement.entity.MedicalHistoryQuery;
import com.menhai.personmanagement.services.MedicalHistoryQueryService;
import com.menhai.personmanagement.utils.ExportSysMedicalHistoryQueryInfoExcel;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestController
@RequestMapping("/MedicalHistoryQuery")
public class MedicalHistoryQueryController {
	@Autowired
	private MedicalHistoryQueryService MedicalHistoryQueryService;
	
	@RequestMapping("/selectQuery")
	public List<MedicalHistoryQuery> selectQuery (MedicalHistoryQuery MedicalHistoryQuery){
		List<MedicalHistoryQuery> MedicalHistoryQueryList = new ArrayList<MedicalHistoryQuery>();
		MedicalHistoryQueryList = MedicalHistoryQueryService.selectQuery(MedicalHistoryQuery);
        return MedicalHistoryQueryList;
   }
	
	@GetMapping("/export")
    public void exports(HttpServletResponse response){
        try {
            List<MedicalHistoryQuery> list = new ArrayList<>();
            ServletOutputStream out = response.getOutputStream();
            new ExportSysMedicalHistoryQueryInfoExcel().export(list, out, response);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
